<template>
  <a-form-model ref="form"  :rules="rules" :model="form" layout="vertical" class="rx-a-form-vertical">
    <a-form-model-item :label="i18n('form.processDefine','流程定义')" prop="flowDef" >
      <rx-input-button    @click="selectFlow" v-model="form.flowDef" ></rx-input-button>
    </a-form-model-item>
    <a-form-model-item :label="i18n('form.statusField','状态字段')">
      <a-input v-model="form.status"  ></a-input>
    </a-form-model-item>
  </a-form-model>
</template>

<script>
    import {Dialog} from "@lowcode/jpaas-common-lib";
    export default {
      name: "renderConfig_startflow",
      props:["layerid","destroy"],
      data(){
        return {
          labelCol: {span: 6},
          wrapperCol: {span: 18},
          idx_: 1,
          rules: {
            flowDef: [
              {required: true, message: this.i18n('form.processDefine','流程定义'), trigger: 'blur'},
            ]
          },
          form:{
              flowDef:{},
              status:"INST_STATUS_",
              alias:""
          }
        }
      },
      methods:{
          i18n(name,text,key){
              return this.$ti18(name,text,"formCellRender",key);
          },
        validate(callback) {
            this.$refs.form.validate(valid => {
                if (valid) {
                    callback();
                }
            });
        },
        getData(){
            return this.form;
        },
        setData(data,fieldDts){
             if(!data){
                 return;
             }
             this.form=Object.assign(this.form,data) ;
        },
        selectFlow(){
            var config = {curVm: this, widthHeight:['1000px','700px'],  data: {single:true}};
            var self_=this;
            Dialog.openBpmDefDialog(config,function (data) {
                var obj={value:data.key,text:data.name};
                var str=JSON.stringify(obj);
                self_.form.flowDef=str;
                self_.form.alias=data.key;
            })
        }
      }
    }
</script>

<style scoped>

</style>